<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use App\User;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Illuminate\Http\Request;

class TextController extends Controller
{
    /*
     * 渲染添加页面
     */
    public function index(Content $content)
    {
        return $content->body(view('text.add'));

    }
       /*
        * 添加方法
        * 传值参数；post
        */
    public function dataAdd(Request $request)
    {
        //接收传过来的数据
        $name = $request['name'];
        $pwd = $request['pwd'];
        $model = new User();//实例化模型层
        $data = $model->dataAdd($name,$pwd);
        if($data)//进行判断
        {
            //添加成功跳转
            return redirect('text.show');
        }else{
            //添加失败提示
            echo "添加失败";
        }
    }

    /**
     * @param Content $content
     * @return Content
     * 展示方法
     * 传值参数：get
     */
    public function dataShow(Content $content)
    {
        $model = new User();//实例化
        $data = $model->dataShow();
        //数据发送到视图层
        return $content->body(view('text.show',['data'=>$data]));
    }
}
